package com.nord.Registration;

import java.util.HashMap;
import java.util.List;

import com.nord.R;
import com.nord.R.id;
import com.nord.R.layout;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class RegistrationAdapter extends SimpleAdapter {

	Context context;
	List<HashMap<String, String>> data;

	public RegistrationAdapter(Context context,
			List<HashMap<String, String>> data, int resource, String[] from,
			int[] to) {
		super(context, data, resource, from, to);
		this.context = context;
		this.data = data;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.list_registration, parent,
				false);

		final TextView listData = (TextView) rowView.findViewById(R.id.regListData);

		if(data.get(position).get("checkbox") == null)
			listData.setText(data.get(position).get("position") + ". " + data.get(position).get("name"));
		else
			listData.setText(data.get(position).get("position") + ". " + data.get(position).get("name") + " - " + data.get(position).get("checkbox"));
		return rowView;

	}

}
